import {makeAutoObservable} from "mobx";

class TaskStore {
    list = [
        {
            id: 1,
            name: 'react',
            isDone: true
        },
        {
            id: 2,
            name: 'vue',
            isDone: false
        }
    ]

    constructor() {
        makeAutoObservable(this)
    }

    singleCheck(id, done) {
        const newList = this.list.map(item => {
            // item.id===id?item.isDone=done:item.done
            if (item.id === id) {
                item.isDone = done
            }
            return item;
        })
        console.log(newList,'2222222222')

        // const item= this.list.find(item=>item.id===id);
        // console.log(item,'item')
        // item.isDone=done;

    }
    allCheck(done){
        //this.list.every(item=>item.isDone=done);
        this.list.forEach(item=>item.isDone=done)
    }
    get isAll(){
        return  this.list.every(item=>item.isDone);
    }
}

export {TaskStore}